package com.wanshu.service.impl;

import com.wanshu.dao.DishDao;
import com.wanshu.entity.Dish;
import com.wanshu.service.DishService;
import com.wanshu.util.ResultUtil;
import org.apache.log4j.Logger;

import java.util.List;

public class DishServiceImpl implements DishService {

    private static Logger logger = Logger.getLogger(DishServiceImpl.class);
    private DishDao dishDao;

    public void setDishDao(DishDao dishDao) {
        this.dishDao = dishDao;
    }

    public List<Dish> findAll(){
        List<Dish> all = dishDao.findAll();
        if(all == null){
            logger.debug("暂无数据!");
            return null;
        }else{
            return all;
        }
    }

    @Override
    public List<Dish> findByShopId(Integer shopId) {
        return dishDao.findByShopId(shopId);
    }

    public Dish findById(Integer id){
        return dishDao.findById(id);
    }

    public String insert(Dish dish){
        Integer insert = dishDao.insert(dish);
        if(insert > 0){
            return "新增成功!";
        }else{
            return "新增失败";
        }
    }
}
